/*
 * @lc app=leetcode.cn id=657 lang=javascript
 *
 * [657] 机器人能否返回原点
 */

// @lc code=start
/**
 * @param {string} moves
 * @return {boolean}
 */
var judgeCircle = function(moves) {
    if(moves.length==0)return true
    let x=0,y=0
    for(let i=0;i<moves.length;i++){
        if(moves[i]=="U")y++
        if(moves[i]=="D")y--
        if(moves[i]=="L")x++
        if(moves[i]=="R")x--
    }
    if(x==0&&y==0)return true
    return false
};
// @lc code=end

